package com.open.capacity.util;

import com.open.capacity.model.OrderAndStation;

import java.util.List;

/**
 * @author: y_022
 * @date: 15:19-2021/7/7
 * @description: 泡泡排序
 * 未支付订单按时间排序工具
 */
public class ListSortUtils {
    private  static boolean flag = false;
    public static List<OrderAndStation> sort(List<OrderAndStation> list){
//    public static List<OrderAndStation> sort(List<OrderAndStation> list){
        for (int i = 0; i <list.size()-1; i++) {
                flag=false;
            for (int j = 0; j <list.size()-1-i; j++) {
                if( list.get(j).getCrdate().compareTo(list.get(j+1).getCrdate())<0){
                    OrderAndStation a = list.get(j);
                    list.set(j,list.get(j+1));
                    list.set(j+1,a);
                    flag = true;
                }
            }
            if (flag == false){
                return  list;
            }
        }
        return  list;
    }
}
